﻿using System.Collections.Generic;
using UnityEngine;

public class SpriteAnimation : MonoBehaviour
{
    public GameObject m_Sprite = null;
    public List<Sprite> m_SpriteList = new List<Sprite>();
    public float m_fOffset = 0.2f;


    private SmartTimer m_Timer = new SmartTimer();
    private int m_nPointer = 0;
    private void Start()
    {
        m_Timer.DoReset(m_fOffset);
    }

    private void Update()
    {
        if (m_Timer.DoUpdate())
        {
            m_Sprite.GetComponent<SpriteRenderer>().sprite = m_SpriteList[m_nPointer];
            ++m_nPointer;
            if (m_nPointer >= m_SpriteList.Count)
                m_nPointer = 0;
            m_Timer.DoReset();
        }
    }
}
